package com.mrd.mrdappstore;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
// Android 监听安装和卸载
// http://blog.csdn.net/ithomer/article/details/8240372

public class MyInstalledReceiver extends BroadcastReceiver {
	@Override
	public void onReceive(Context context,Intent intent) {

		if(intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {		// install
			String packageName = intent.getDataString();

			Log.i("homer", "安装了 :" + packageName);
			if(MainActivity.App1packageName.equals(packageName)) {
				Log.i("homer", "插件标识为已安装 :" + packageName);
			}
		}

		if(intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {	// uninstall
			String packageName = intent.getDataString();

			Log.i("homer", "卸载了 :" + packageName);
			if(MainActivity.App1packageName.equals(packageName)) {
				Log.i("homer", "插件标识为未安装 :" + packageName);
			}
		}
	}
}
